package com.dkd.interfaceinfo.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.dkd.interfaceinfo.annotation.AuthCheck;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.interfaceinfo.domain.UserInterfaceInfo;
import com.dkd.interfaceinfo.service.IUserInterfaceInfoService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 用户调用接口关系Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/userinterface/info")
public class UserInterfaceInfoController extends BaseController
{
    @Resource
    private IUserInterfaceInfoService userInterfaceInfoService;

    /**
     * 查询用户调用接口关系列表
     */
    @AuthCheck(mustRole = "admin")
    @GetMapping("/list")
    public TableDataInfo list(UserInterfaceInfo userInterfaceInfo)
    {
        startPage();
        List<UserInterfaceInfo> list = userInterfaceInfoService.selectUserInterfaceInfoList(userInterfaceInfo);
        return getDataTable(list);
    }


    /**
     * 获取用户调用接口关系详细信息
     */
    @AuthCheck(mustRole = "admin")

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userInterfaceInfoService.selectUserInterfaceInfoById(id));
    }

    /**
     * 新增用户调用接口关系
     */
    @AuthCheck(mustRole = "admin")

    @PostMapping
    public AjaxResult add(@RequestBody UserInterfaceInfo userInterfaceInfo)
    {
        return toAjax(userInterfaceInfoService.insertUserInterfaceInfo(userInterfaceInfo));
    }

    /**
     * 修改用户调用接口关系
     */
    @AuthCheck(mustRole = "admin")

    @PutMapping
    public AjaxResult edit(@RequestBody UserInterfaceInfo userInterfaceInfo)
    {
        return toAjax(userInterfaceInfoService.updateUserInterfaceInfo(userInterfaceInfo));
    }

    /**
     * 删除用户调用接口关系
     */
    @AuthCheck(mustRole = "admin")

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userInterfaceInfoService.deleteUserInterfaceInfoByIds(ids));
    }



}
